<?php
	
	if (!defined("EXPONENT")) exit("");
	$obj=null;
	$value_rank=0;
	if (exponent_permissions_check(array("administrate", "configure"),$loc) && isset($_REQUEST['stype'])) {
		$id=0;
		if(isset($_REQUEST['id']))
		{
			$id = intval($_REQUEST['id']);
		}
		$cat=$db->selectObject("linklist_link","id = {$id} and location_data='".serialize($loc)."'");
		$value_rank = $cat->rank;
		if ($cat && ($cat->rank > 0))
		{
			if ($_REQUEST['stype'] == 1) // move down
			{
				$temp = $db->selectObject("linklist_link","location_data='".serialize($loc)."' AND rank > {$value_rank} ORDER BY rank DESC");            
			}
			else
			{
				$temp = $db->selectObject("linklist_link","location_data='".serialize($loc)."' AND rank < {$value_rank} ORDER BY rank DESC");   
			}
			//$sql_where.=" ORDER BY rank DESC";
			//$temp=$db->selectObject("productsmodule_country", "location_data = '{$cat->location_data}'  AND id = {$cat->id}{$sql_where}");
			if ($temp)
			{
				$temp_value=$temp->rank;
				$temp->rank=$cat->rank;
				$cat->rank=$temp_value;
				$db->updateObject($temp,"linklist_link");
				$db->updateObject($cat,"linklist_link");
			}
		}
	} else {
		//echo SITE_403_HTML;
	}
    die();
	//exponent_flow_redirect(SYS_FLOW_ACTION);
?>